<template>
	<div>
		<baseBack></baseBack>
		<div class="content" style="margin-top: 20px;">
			<el-table :data="list.data" style="width: 100%" height="600" border>
				<!-- <el-table-column fixed prop="id" label="客户编号" >
			        </el-table-column> -->
				<el-table-column prop="realname" label="驾照类型">
					<template slot-scope="scop">
						<div>{{$CarType(scop.row.carType) }}</div>
					</template>
				</el-table-column>
				<el-table-column prop="realname" label="科目">
					<template slot-scope="scop">
						<div>{{$SubjectType(scop.row.subject)}}</div>
					</template>
				</el-table-column>
				<el-table-column prop="useTimeStr" label="答题用时(分钟)">
					<template slot-scope="scop">
						<div>{{scop.row.useTimeStr}}</div>
					</template>
				</el-table-column>

				<el-table-column prop="grade" label="得分">
					<template slot-scope="scop">
						<div>{{scop.row.grade}}分</div>
					</template>
				</el-table-column>

				<el-table-column prop="createTime" label="模拟时间">
					<template slot-scope="scop">
						<div>{{scop.row.createTime}}</div>
					</template>
				</el-table-column>
				<el-table-column label="操作">
					<template slot-scope="scop">
						<el-button size="mini" @click="flow(scop.row)" type="primary">
							{{status?'继续模拟':'错题练习'}}
						</el-button>
						<el-button size="mini" @click="del(scop.row)" type="danger" v-if="status">
							删除
						</el-button>
					</template>
				</el-table-column>
			</el-table>
			<div style="display: flex;justify-content: flex-end;margin: 20px 0;">
				<basePagination :size="list.perPage" :page="list.currentPage" :total="list.total"
					@SizeChange='SizeChange' @CurrentChange='CurrentChange' />
			</div>
		</div>
	</div>
</template>

<script>
	import loader from '@/components/base/basePagination/controls.js';
	export default {
		mixins: [loader],
		data() {
			return {
				initial: {
					geturl: "/user/examLog",
					params: {}
				},
				list: {},
				loading: true,
				status: ''
			}
		},
		created() {
			if (this.$route.query.status) {
				this.status = this.$route.query.status;
			}
			this.jiazai()
		},
		methods: {
			flow(e) {
				if (!this.status) {
					this.$Go('case', {
						txt: '模拟考试',
						car: this.$CarType(e.carType),
						carId: e.carType,
						subject: this.$SubjectType(e.subject),
						subjectId: e.subject,
					}, );
				} else {
					this.$Go('case', {
						txt: '错题库',
						id: e.id
					});
				}
			},
			del(e) {
				this.axios.post("/user/clearLog", {
					id:e.id,
					type:1
				}).then(res => {
                    this.jiazai()
				}).catch(error => {
					
				})
			},
			jiazai() {
				this.getData(this.initial.params).then(res => {
					this.list = res;
					this.loading = false;
				}).catch(err => {

				})
			},
		}
	}
</script>

<style>
</style>
